
<?php
session_start();
if (!$_SESSION['user']) {
    header('location:index.php?status=no-authentication');
}
?>

<html>
    <head>
        <meta charset="utf-8">
        <title>Admin Panel</title>


        <link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css">
        <link rel="stylesheet" type="text/css" href="../bootstrap/css/bootstrap-responsive.css">
        
        <link rel="stylesheet" type="text/css" href="../css/font-awesome.min.css">

        <script type="text/javascript" src="../js/jquery.js"></script>
        <script type="text/javascript" src="../js/bootstrap.min.js"></script>


        <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

       <script>
          $(function() {
            $( "#deadline" ).datepicker();
          });


            var url=window.location.href;

            if (url.search("=")!=-1) {
                var b=url.indexOf("=")+1;
                var param=url.substr(b);
                var index = url.indexOf("?");
                var new_url = url.substr(0,index);
                

                if (param=='ok') {
                    alert("data inserted successfully, thanks!");
                    window.location.href=new_url;

                }

                else {
                    alert("Data was not inserted, try again!");
                    window.location.href=new_url;
                }
            }

            else
            {

                
            }




        </script>



  <style type="text/css"></style>


    </head>
    <body>

        <div class="container">

            <h1>welcome <?php echo $_SESSION['user']; ?></h1>
            <a href="logout.php" class="btn btn-success " >log out</a>


            <div class="tabbable tabs-left">

                <ul class="nav nav-tabs">
                    <li class="active"><a href="#tab1" data-toggle="tab"><h5>Veiw All Faqs <i class="fa fa-book"></i></h5></a></li>
                       <li><a href="#tab2" data-toggle="tab"><h5>Post a Faq <i class="fa fa-book"></i></h5></a></li>
                    <li><a href="#tab3" data-toggle="tab"><h5>View All Jobs <i class="fa fa-cut"></i></h5></a></li>
                      <li><a href="#tab4" data-toggle="tab"><h5>Post a job <i class="fa fa-book"></i></h5></a></li>
                    <li><a href="#tab5" data-toggle="tab"><h5>other_jobs <i class="fa fa-edit"></i></h5></a></li>

                </ul>

                <div class="tab-content">
                    <div class="tab-pane active" id="tab1">
                        <?php
                        $mysqli = new mysqli('localhost', 'me77', 'taktaz', 'ntz') or die("Connetion error!");


                        $query2 = "select * from faq ";
                        $res = $mysqli->query($query2);

                        echo "<table class='table table-hover' border='1'><tr class='success'><th>#</th><th>Question</th><th>Answer</th></tr>";
                        while ($new = $res->fetch_array()) {
                          echo "<tr><td>".$new['id']."</td><td>".$new['q']."</td><td>".$new['a']."</td></tr>";
                      }
                        echo "</table>";
                       
                        ?>


                    </div>

                    <div class="tab-pane" id="tab2">

                             <form class="form" action="insert.php" method="POST">
                               Qestion: <br/><textarea cols="100" name="q" required></textarea> <br/>
                                Answer: <br/><textarea  cols="100"  name="a" required></textarea> <br/><br/>
                                 <input type="submit" value="Save" name="submit" class="btn btn-info">
                            </form>

                    </div>


                    <div class="tab-pane" id="tab3">
                         <?php
                        $mysqli = new mysqli('localhost', 'me77', 'taktaz', 'ntz') or die("Connetion error!");

                        $query2 = "select * from jobs ";
                        $res = $mysqli->query($query2);

                        echo "<table border='1' class='table table-hover'><tr class='success'><th>ID</th><th>Title</th><th>Quentity</th><th>Description</th></th><th>Requirement</th><th>Category</th><th>deadline</th></tr>";

                        while ($new2 = $res->fetch_array()) {
                          echo "<tr><td>".$new2['id']."</td>   <td>".$new2['title']."</td>    <td rows='2'>".$new2['quantity']."</td>    <td rows='2'>".$new2['description']."</td>    <td>".$new2['req']."</td>     <td>".$new2['category']."</td>     <td>".$new2['deadline']."</td></tr>";
                      }
                        echo "</table>";
                       
                        ?>

                    </div>

                    <div class="tab-pane" id="tab4">
                            <form class="form" action="insertjob.php" method="POST">
                            Title:<br/><input type="text" name="title"  required></br>
                            Quentity:<br/><input type="text" name="quantity"  required></br>
                            description: <br/><textarea cols="100" name="description" required></textarea> <br/>
                            Requerment: <br/><textarea  cols="100"  name="req" required></textarea> <br/><br/>
                            <br><br><br><br><br><br><br><br>

                            <p>Deadline: <input type="text" id="deadline" name="deadline"></p>
                          
                                
                             Category:<select name="category">
                                    <option value="networking" >Network and Engineering</option>
                                    <option value="finance">Finance and Management</option>
                                    <option value="sales">Sales and Marketing</option>
                                     <option value="others">Other Jobs</option>

                                </select>    

                                 <input type="submit" value="Save the job" name="submit" class="btn btn-info">

                            </form>

                    </div>

                    <div class="tab-pane" id="tab5">
                     <?php
                        $mysqli = new mysqli('localhost', 'me77', 'taktaz', 'ntz') or die("Connetion error!");

                        $query2 = "select * from jobs ";
                        $res = $mysqli->query($query2);

                        echo "<table class='table table-hover'><tr><th>#</th><th>Title</th><th>Description</th></th><th>Requirement</th><th>Category</th><th>deadline</th></tr>";

                        while ($new2 = $res->fetch_array()) {
                          echo "<tr><td>".$new2['id']."</td><td>".$new2['title']."</td><td rows='2'>".$new2['description']."</td><td>".$new2['req']."</td><td>".$new2['category']."</td><td>".$new2['deadline']."</td></tr>";
                      }
                        echo "</table>";
                       
                        ?>

                    </div>
                </div>
            </div>

        </div>
    </body>
        </html>